import akshare as ak

# 获取股票日线行情数据
stock_data = ak.stock_zh_a_daily(symbol="sz000001", start_date="2022-01-01", end_date="2022-12-31")
print(stock_data)

# # 获取基金净值数据
# fund_data = ak.fund_em_open_fund_info(fund="000001", start_date="2022-01-01", end_date="2022-12-31")
# print(fund_data)

# 获取期货日线行情数据
# futures_data = ak.futures_zh_daily(symbol="cu2103", start_date="2022-01-01", end_date="2022-12-31")
# print(futures_data)

# 获取外汇汇率数据
# exchange_rate_data = ak.forex_ak_m1()
# print(exchange_rate_data)

# 获取股票日线行情数据
# stock_data = ak.stock_zh_a_daily(symbol="sz000001", start_date="2022-01-01", end_date="2022-12-31")
# import matplotlib.pyplot as plt
# # 绘制股票价格走势图
# plt.plot(stock_data["date"], stock_data["close"])
# plt.xlabel("Date")
# plt.ylabel("Close Price")
# plt.title("Stock Price Trend")
# plt.show()

# 获取股票日线行情数据
stock_data = ak.stock_zh_a_daily(symbol="sz000001", start_date="2022-01-01", end_date="2022-12-31")

# 计算股票收益率
stock_data["return"] = stock_data["close"].pct_change()
print(stock_data["return"].describe())